package belf.migrate.engine.job.exception;

import belf.migrate.core.exception.BelfErrorCode;
import belf.migrate.core.exception.BelfRuntimeException;

import java.util.logging.ErrorManager;

public class ConvertViewException extends BelfRuntimeException {
    /** 待转化的视图创建语句 */
    private String ddl;
    /** 无法替换的函数 */
    private String function;
    private String message;


    public ConvertViewException(BelfErrorCode eErrorCode, String errorMessage) {
        super(eErrorCode, errorMessage);
        this.message = errorMessage;
    }

    public ConvertViewException(BelfErrorCode eErrorCode, String errorMessage, String ddl, String function) {
        super(eErrorCode, errorMessage);
        this.ddl = ddl;
        this.function = function;
        this.message = errorMessage;
    }

    public String getDdl() {
        return ddl;
    }

    public String getFunction() {
        return function;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("ErrorCode:");
        sb.append(geteErrorCode().getCode());
        sb.append(", message:");
        sb.append(message);
        return sb.toString();
    }
}
